// 异常处理与new操作符

#include <iostream>
using namespace std;

int main() {
    int size;
    cout << "输入一维数组的大小: ";
    cin >> size;

    int* p;
    try {
        p = new int[size];
        if (!p) {
            throw 100;
        }
        cout << "如果该行被显示出来，则程序没有抛出异常.\n";
    }
    catch (int i) {
        cout << "内存不够，抱歉\n";
    }

    cout << "完毕\n";
}